import { join } from 'path'
import * as _ from 'lodash'

export default {
  app: {
    name: 'nest.js 项目实践',
    port: 8870,
    hostName: 'localhost',
  },

  // session 设置
  session: {
    secret: 'keyword',
    cookie: { maxAge: 60000 }
  },

  orm: {
    // 存储数据库
    type: _.toString('mysql'), // 数据库类型
    host: 'localhost',
    port: _.toNumber(3306),
    username: 'root',
    password: 'root',
    database: 'nestjs',
    entities: [join(__dirname, '../../**/**.entity{.ts,.js}')],
    migrations: ['migration/*.ts'],
    timezone: 'UTC',
    charset: 'utf8mb4',
    multipleStatements: true,
    dropSchema: false,
    synchronize: true, // 此处为true才能自动建表
    logging: false,
    cache: {
      // 缓存数据库
      type: _.toString('ioredis'),
      options: {
        host: 'localhost',
        port: 6379,
        family: 4,
        password: '',
        keyPrefix: '',
        db: 15
      },
    },
  },
}